def is_dominated(candidate, other):
    return all(c >= o for c, o in zip(candidate, other)) and any(c > o for c, o in zip(candidate, other))

def pareto_layering(solutions):
    layers = []
    remaining_solutions = solutions[:]

    while remaining_solutions:
        layer = []
        non_dominated = []

        for candidate in remaining_solutions:
            if not any(is_dominated(candidate, other) for other in remaining_solutions):
                layer.append(candidate)
            else:
                non_dominated.append(candidate)

        layers.append(layer)
        remaining_solutions = non_dominated

    return layers

# Example usage
solutions = [
    (10, 200),  # Solution 1
    (15, 180),  # Solution 2
    (20, 160),  # Solution 3
    (4,5),(5,4),
    (30,40),(20,159)
]

layers = pareto_layering(solutions)
print(len(layers[0]))
# for i, layer in enumerate(layers):
#     print(f"Layer {i+1}: {layer}")
